package dao;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate5.HibernateCallback;
import org.springframework.stereotype.Repository;
import pojo.Patient;
import pojo.Registry;

import java.util.List;

@Repository
public class PatientDAO extends  BaseDAO<Patient> {
    public PatientDAO() {
        super(Patient.class);
    }

    public List<Patient> queryByCard(String idCard) {
        return getHibernateTemplate().execute(new HibernateCallback<List<Patient>>() {
            @Override
            public List<Patient> doInHibernate(Session session) throws HibernateException {
                List<Patient> list = session.createQuery("from Patient where idCard =:i")
                        .setParameter("i", idCard)
                        .list();
                return list;
            }
        });
    }

}
